use std::env;
use std::process;
use minigrep::{run, Config};

fn main() {
    // 对 build 返回的 `Result` 进行处理
    let config = Config::build(env::args()).unwrap_or_else(|err| {
        println!("Problem parsing arguments: {err}");
        process::exit(1);
    });

    println!("Searching for {} in {}", config.query, config.file_path);

    // 读取文件
    println!("Reading file...");
    if let Err(e) = run(config) {
        println!("Application error: {e}");
        process::exit(1);
    }
}


